<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkAlignment extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}();";
		if(($sTopPadding=$oObject->getProperty('top_padding'))===null){// 四周留空
			$sTopPadding='0';
		}
		if(($sBottomPadding=$oObject->getProperty('bottom_padding'))===null){
			$sBottomPadding='0';
		}
		if(($sLeftPadding=$oObject->getProperty('left_padding'))===null){
			$sLeftPadding='0';
		}
		if(($sRightPadding=$oObject->getProperty('right_padding'))===null){
			$sRightPadding='0';
		}
		$sCompiled.="\t\t{$sVariableName}->set_padding({$sTopPadding},{$sBottomPadding},$sLeftPadding,$sRightPadding);";
		if(($sXAlign=$oObject->getProperty('xalign'))===null){// 排列 和 缩放
			$sXAlign='0.5';
		}
		if(($sYAlign=$oObject->getProperty('yalign'))===null){
			$sYAlign='0.5';
		}
		if(($sXScale=$oObject->getProperty('xscale'))===null){
			$sXScale='1.00';
		}
		if(($sYScale=$oObject->getProperty('yscale'))===null){
			$sYScale='1.00';
		}
		$sCompiled.="\t\t{$sVariableName}->set({$sXAlign},{$sYAlign},$sXScale,$sYScale);";
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);// 父/子 窗体变量名
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetName=$oChildWidget->getWidgetId();// 子窗体名
		$sCompiled="\t\t{$sChildWidgetVariableName}=self::getWidget('{$sChildWidgetName}',\$arrObjectForSignal);";
		$sCompiled.="\t\t{$sParentVariableName}->add({$sChildWidgetVariableName});";
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
